home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / CCDBMS.ZIP / DBCMD.CPP < prev    next >
C/C++ Source or Header  |  1997-03-18  |  3KB  |  98 lines

  1. // =================================================================
  2. // Dbcmd.cpp 
  3. // =================================================================
  4. // Harold Kasperink / John Dekker 
  5. // Dr. Dobb's Journal 1997
  6. // =================================================================
  7. // Dbase command class implementation
  8. // =================================================================
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <iostream.h>
  12.  
  13. #include "dbarray.h"
  14.  
  15. extern "C" long DbCmdFunc(void *pCmd, const char *pszFile, long lLine, long lSql)
  16. {
  17.     CDbCommand *pTmp = (CDbCommand *)pCmd;
  18.     
  19.     pTmp->Location(pszFile, lLine);
  20.     pTmp->Sql(lSql);
  21.  
  22.     return lSql;
  23. }
  24.  
  25. ////////////////////////////////////////////////////////////////////
  26. // CDbCommand::CDbCommand
  27. ////////////////////////////////////////////////////////////////////
  28. CDbCommand::CDbCommand()
  29. {
  30.     m_pDbase = 0;
  31. }
  32.  
  33. ////////////////////////////////////////////////////////////////////
  34. // CDbCommand::CDbCommand
  35. ////////////////////////////////////////////////////////////////////
  36. CDbCommand::CDbCommand(CDbase &dbase)
  37. {
  38.     m_pDbase = &dbase;
  39. }
  40.  
  41. ////////////////////////////////////////////////////////////////////
  42. // CDbCommand::~CDbCommand
  43. ////////////////////////////////////////////////////////////////////
  44. CDbCommand::~CDbCommand()
  45. {
  46. }
  47.  
  48. ////////////////////////////////////////////////////////////////////
  49. // CDbCommand::ThrowDbError
  50. ////////////////////////////////////////////////////////////////////
  51. void CDbCommand::ThrowDbError(boolean bUnlock)
  52. {
  53.     if (bUnlock && m_pDbase)
  54.         CArrayDbase::ReleaseDbase(*m_pDbase);
  55.  
  56.     // Now Throw the Error Message
  57. }
  58.  
  59. ////////////////////////////////////////////////////////////////////
  60. // CDbCommand::Dbase
  61. ////////////////////////////////////////////////////////////////////
  62. CDbase *CDbCommand::Dbase()
  63. {
  64.     if (m_pDbase == 0) {
  65.         // throw error
  66.         ;
  67.     }
  68.     
  69.     return m_pDbase;
  70. }
  71.  
  72. ////////////////////////////////////////////////////////////////////
  73. // CDbCommand::Dbase
  74. ////////////////////////////////////////////////////////////////////
  75. void CDbCommand::Dbase(CDbase &dbase)
  76. {
  77.     m_pDbase = &dbase;
  78. }
  79.  
  80. ////////////////////////////////////////////////////////////////////
  81. // CDbCommand::Location
  82. ////////////////////////////////////////////////////////////////////
  83. void CDbCommand::Location(const char *pszFile, long lLine)
  84. {
  85.     m_pszFile = pszFile;
  86.     m_lLine = lLine;
  87. }
  88.  
  89. ////////////////////////////////////////////////////////////////////
  90. // CDbCommand::Sql
  91. ////////////////////////////////////////////////////////////////////
  92. void CDbCommand::Sql(long lSql)
  93. {
  94.     m_lSql = lSql;
  95. }
  96.  
  97.  
  98.